
public class Teacher2 //类声明
{
	//类体
	String name,title,course,research,office;//定义成员变量，类型均为字符串
	Teacher2(){}//定义一个无参数的构造方法
	Teacher2(String name,String title,String course,String research,String office)//有参数的构造方法
	{
		this.name=name;
		this.title=title;
		this.course=course;
		this.research=research;
		this.office=office;
	}
	public void getTeacher()//读取老师的信息
	{
		System.out.println("姓名:"+name);
		System.out.println("职位:"+title);
		System.out.println("主讲课程:"+course);
		System.out.println("研究方向:"+research);
		System.out.println("办公室:"+office);
	}
	public void setTitle(String title)//更改老师的职位
	{
		this.title=title;
	}
	public void setCourse(String course)//更改老师的课程
	{
	this.course=course;
	}
	public void setResearch(String research)//更改老师的研究方向
	{
	this.research=research;
	}
	public void setOffice(String office)//更改老师的办公室
	{
	this.office=office;
	}
	public static void main(String[] args)//在类体中定义的main方法
	{
		//声明对象t2
	    Teacher2 t2;
	    //使用有参数的构造方将t2实例化
	    t2=new Teacher2("Chen jianyong","associate professor","English","Marketing","A305");
	    //读取t2的信息并输出
	    t2.getTeacher();
	    //更改老师的信息
	    t2.setTitle("professor");
	    t2.setCourse("Professional Basic English");
	    t2.setResearch("Market forecasting");
	    t2.setOffice("A315");
	    //输出老师的信息
	    System.out.println();//打印空行，作为分隔行
	    t2.getTeacher();
	}
}
